package com.gomtel.smartdevice.ui.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.gomtel.smartdevice.R;
import com.gomtel.smartdevice.bean.ToolsContentBean;
import com.gomtel.smartdevice.utils.CommonViewHolder;

import java.util.ArrayList;

/**
 * Created by Administrator on 2018/5/15 0015.
 */

public class ToolsAdapter extends BaseAdapter {

    private ArrayList<ToolsContentBean> toolsContentListBeen;
    private Context context;

    public ToolsAdapter(ArrayList<ToolsContentBean> toolsContentBeen, Context context) {
        this.toolsContentListBeen = toolsContentBeen;
        this.context = context;
    }

    @Override
    public int getCount() {
        return toolsContentListBeen.size();
    }

    @Override
    public Object getItem(int i) {
        return toolsContentListBeen.get(i);
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        ToolsContentBean toolsContentBean = toolsContentListBeen.get(i);
        CommonViewHolder holder = CommonViewHolder.createCVH(view, viewGroup, R.layout.item_tools);
        TextView tools_type = holder.getTv(R.id.tools_type);
        TextView tools_content = holder.getTv(R.id.tools_content);
        ImageView tools_img = holder.getIv(R.id.tools_img);
        tools_type.setText(toolsContentBean.getToolsName());
        tools_content.setText(toolsContentBean.getToolsContent());
        switch (toolsContentBean.getToolsType()) {
            case 0:
                tools_content.setTextColor(context.getResources().getColor(R.color.color_fatigue_red));
                tools_img.setBackground(context.getResources().getDrawable(R.drawable.pedometer));
                break;
            case 1:
                tools_content.setTextColor(context.getResources().getColor(R.color.color_fatigue_red));
                tools_img.setBackground(context.getResources().getDrawable(R.drawable.ecg));
                break;
            case 2:
                tools_content.setTextColor(context.getResources().getColor(R.color.color_fatigue_red));
                tools_img.setBackground(context.getResources().getDrawable(R.drawable.bp));
                break;
            case 3:
                tools_content.setTextColor(context.getResources().getColor(R.color.color_fatigue_red));
                tools_img.setBackground(context.getResources().getDrawable(R.drawable.feel_the_pulse));
                break;
            case 4:
                tools_content.setTextColor(context.getResources().getColor(R.color.color_fatigue_red));
                tools_img.setBackground(context.getResources().getDrawable(R.drawable.heart_rate));
                break;
            case 5:
                tools_content.setTextColor(context.getResources().getColor(R.color.color_fatigue_red));
                tools_img.setBackground(context.getResources().getDrawable(R.drawable.monitoring_of_saliva));
                break;
        }

        return holder.convertView;
    }
}
